<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Warehouse Transfer IN </title>
<script language="javascript">
function enableUpload(){
	document.getElementById("sub_upload").disabled = false;
	}

</script>
</head>
<body style="font-family:Arial, Helvetica, sans-serif;">

<h1>Goods Receive From Supplier (GI)</h1>
<p>***********************************<br />
  1.Scan Barcode and Input the Qty<br />
  2.Click 
  &quot;Add Record&quot;<br />
  3.You may Click The &quot;Remove&quot; Button if You Made Mistakes<br />
  4.After All Record Scaned ,Fill In Your Name<br />
  5.Finally,Click &quot;Save These Records&quot;
  <br />
*********************************** </p>
<p>1. Scan the Barcode and <br />
  
  <?php
$arrProducts = array();
$end = 0;

$rProduct = new Model_DbTable_Pr_Prproducts();
$supplier = new Model_DbTable_Suppliers();
$supplierList = $supplier->listAllSuppliers();

if($_POST){
	//unset($arrProducts);
	$arrProducts = unserialize(base64_decode(trim($_POST['saved_arr'])));
	//echo $_POST['saved_arr'];
	$end = count($arrProducts);
	$tmpstr = trim($_POST['barcode_code'])."|".trim($_POST['barcode_qty']);
	$pLine = $rProduct->getProductByCode(trim($_POST['barcode_code']));
		//$pLine = $rProduct->find($idPro);	
	if($pLine){		
		$tmpstr = trim($_POST['barcode_code'])."|".trim($_POST['barcode_qty']);
		$arrProducts[$end] = $tmpstr;
	}else{
		echo "<script type='text/javascript'>alert('Goods Not Exist, Please create barcode first');</script>";
	}
	
	}
if($_GET){
	
	$i = $_GET['rm'];
	//echo $i;
	$arrProducts = unserialize(base64_decode(trim($_GET['data'])));
	array_splice($arrProducts,$i,1);
	}	

?>
  
</p>
<table width="800" border="0" cellspacing="1" cellpadding="5" bgcolor="#333">
  <tr>
    <td bgcolor="#FFFFFF">Scan BarCode:<br /></td>
    <td rowspan="1" bgcolor="#FFFFFF" style="padding:0px;"><form id="form1" name="form1" method="post" action="/repairparts/warehouse-goods-receive">
    <table width="100%" border="0" cellspacing="1" cellpadding="5">
  <tr>
    <td colspan="1"><input type="text" name="barcode_code" id="barcode_code" />
Qty:
      [
  <label for="textfield2"></label>
  <input type="text" name="barcode_qty" id="barcode_qty" size="10" value="1" />
]  
<input type="hidden" name="saved_arr" id="saved_arr" value="<?php echo base64_encode(trim(serialize($arrProducts)));?>"/>
<input type="button" name="button" id="button" value="Add Product" onclick="javascript:document.form1.submit();" /></td>
  </tr>
</table></form></td>
  </tr>
  <tr>
    <td width="150" bgcolor="#FFFFFF">Records to Upload:</td>
    <td bgcolor="#FFFFFF"><form id="form2" name="form2" method="post" action="/repairparts/save-wh-gi">
      
       
        <h2>Record For Save into Database</h2> 
      <hr />
      
      <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#666666" style="font-size:12px;">
  <tr>
    <th bgcolor="#FFFFFF" style="width:150px;" scope="col" >BarCode</th>
    <th bgcolor="#FFFFFF" scope="col">Title</th>
    <th bgcolor="#FFFFFF" style="width:40px;" scope="col" >Qty</th>
    <th bgcolor="#FFFFFF" style="width:40px;" scope="col" >Act</th>
  </tr>
    <?php
	
    foreach($arrProducts as $key => $value){
	$arrTmp = explode("|",$value);
	?>
  <tr>
    <td bgcolor="#FFFFFF"><?php echo $arrTmp[0];?></td>
    <td bgcolor="#FFFFFF"><?php
   echo $rProduct->getProductDes(trim($arrTmp[0])); 
	?>
    </td>
    <td bgcolor="#FFFFFF"><?php echo $arrTmp[1];?></td>
    <td bgcolor="#FFFFFF"><?php
    echo "<input type=\"hidden\" name=\"upload[]\" value=\"".$value."\" />";
			echo "<a href=\"?rm=".$key."&data=".base64_encode(trim(serialize($arrProducts)))."\">Remove</a>";
	?></td>
  </tr>
    <?php	
		}
	?> 
    </table>
    <br />
 <label for="staff_name"></label>
        Staff Name:
        <input type="text" name="staff_name" id="staff_name" onchange="enableUpload()" />
        Supplier:<select id = "supplier" name = "supplier">
				<option value = "351">BEN</option>
				<option value = "354">Terry</option>
                <option value = "34">EB</option>
				<option value = "36">IM</option>
				<option value = "40">IF</option>
				<option value = "38">LU</option>
				<option value = "39">RAF</option>
				<option value = "99">CHINA</option>
			</select>
        <br />
        <br />
  <input name="sub_upload" id="sub_upload" value="SAVE INTO DATABASE" type="submit" disabled="disabled" /><br />
        <br />
    
    </form></td>
  </tr>

</table>
    <script language="javascript">
    document.getElementById('barcode_code').focus(); 
    </script> 
    <div style=" font-size:10px; color:#666;float:left;" >Developer:Norman,Date:2015-01-28</div>
</body>
</html>
